package com.ian.service.impl;

import com.ian.service.MessageService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

/**
 * @author Witt
 * @version 1.0.0
 * @date 2022/5/13
 */
//@Service
public class MessageServiceImpl implements MessageService {
    @PreAuthorize("authenticated")
    @Override
    public String getMessage() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        System.out.println("authentication.getPrincipal(): " + authentication.getPrincipal());
        System.out.println("authentication.getCredentials(): " + authentication.getCredentials());
        System.out.println("authentication.getAuthorities(): " + authentication.getAuthorities());
        System.out.println("authentication.getDetails(): " + authentication.getDetails());
        return "Hello, " + authentication;
    }
}
